import junit.framework.TestCase;
import de.unibi.comet.ac.LcpArrayFactory;

public class LcpArrayFactoryTest extends TestCase {

	public void testSimple() {
		String s = "mississippi";
		int [] suffix_array = {10,7,4,1,0,9,8,6,3,5,2};
		int [] lcp = LcpArrayFactory.create(s, suffix_array);
		assertEquals(0, lcp[0]);
		assertEquals(1, lcp[1]);
		assertEquals(1, lcp[2]);
		assertEquals(4, lcp[3]);
		assertEquals(0, lcp[4]);
		assertEquals(0, lcp[5]);
		assertEquals(1, lcp[6]);
		assertEquals(0, lcp[7]);
		assertEquals(2, lcp[8]);
		assertEquals(1, lcp[9]);
		assertEquals(3, lcp[10]);
	}

	public void testSetOfStrings() {
		String s = "$abc$bc$ba$";
		int [] suffix_array = {10,0,7,4,9,1,8,5,2,6,3};
		int [] lcp = LcpArrayFactory.create(s, suffix_array);
		assertEquals(0, lcp[0]);
		assertEquals(0, lcp[1]);
		assertEquals(0, lcp[2]);
		assertEquals(0, lcp[3]);
		assertEquals(0, lcp[4]);
		assertEquals(1, lcp[5]);
		assertEquals(0, lcp[6]);
		assertEquals(1, lcp[7]);
		assertEquals(2, lcp[8]);
		assertEquals(0, lcp[9]);
		assertEquals(1, lcp[10]);
	}
	
}
